package com.cloud.common.tenant;

import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @Author Aijm
 * @Description  对TenantHandler 的外部实现
 * @Date 2019/5/8
 */
@Slf4j
@Component
public class CloudTenantHandler implements TenantHandler {

//    @Autowired
//    private CloudTenantConfigProperties properties;
    /**
     * 获取租户值
     * @return
     */
    @Override
    public Expression getTenantId() {
        return new LongValue(1L);
    }

    /**
     * 租户字段名
     * @return
     */
    @Override
    public String getTenantIdColumn() {
        return  "tenant_id";
    }


    /**
     * 根据表名判断是否进行过滤
     * @param tableName 表名
     * @return 是否进行过滤
     */
    @Override
    public boolean doTableFilter(String tableName) {

        return true;
    }
}
